<template>
  <div class="container">
    <div class="cheader2">
      <van-icon
        @click="goBack"
        class="chl"
        name="arrow-left"
        color="#000"
        size="20"
      />
      <div class="chtitle">社区信息</div>
      <div class="djbox"></div>
    </div>
    <div class="mbox">
      <!-- <div class="mtitle">总社区({{ nodeList.length }})</div> -->
      <div class="mul" v-if="nodeList.length">
        <div class="mli" v-for="item in nodeList" :key="item.id">
          <card-item :propItems="nodePropItems" :detail="item"></card-item>
        </div>
      </div>
      <van-empty
        v-else
        description="暂无数据"
        image-size="100"
        :image="require('@/assets/images/null.png')"
      />
    </div>
  </div>
</template>
  
  <script setup lang='ts'>
import { reactive, onMounted, ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import CardItem from "@/components/CardItem/index.vue";
import http from "@/utils/http";

const route = useRoute();
const router = useRouter();
const nodeList = ref<any>([]);
const id = route.query.id
onMounted(() => {
  getList();
});
const getList = async () => {
  const ret:any = await http.get("user/user/all/child/"+id);
  if (ret.code === 0) {
    nodeList.value = ret.data;
  }
};
const goBack = () => {
  router.go(-1);
};
const nodePropItems = reactive([
  {
    name: "用户ID",
    prop: "id",
    copy: true,
    underline: true,
  },
  {
    name: "上级ID",
    prop: "parentId",
    copy: true,
  },
  {
    name: "伞下燃料购买总额",
    prop: "rechargeQuantity",
    ryz: true,
  },
  {
    name: "伞下燃料消耗总额",
    prop: "fuelQuantity",
    ryz: true,
  },
  {
    name: "当前持有燃料数量",
    prop: "fuelBalance",
    ryz: true,
  },
  {
    name: "等级",
    prop: "level",
  },
  {
    name: "社区人数",
    prop: "communityCount",
  },
  {
    name: "注册时间",
    prop: "createTime",
  },
]);
</script>
  
  <style lang="scss" scoped>
.cheader2 {
  width: 100%;
  height: 45px;
  background-color: #fff;
  font-size: 16px;
  color: #000;
  position: fixed;
  top: 0;
  left: 0;
  .chl {
    position: absolute;
    left: 16px;
    top: 50%;
    text-align: center;
    transform: translateY(-50%);
  }
  .chtitle {
    position: absolute;
    left: 50%;
    top: 50%;
    text-align: center;
    transform: translate(-50%, -50%);
  }
  .djbox {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    img {
      width: 16px;
      margin-right: 4px;
    }
    div {
      font-size: 13px;
      color: #878b97;
    }
  }
}
.mbox {
  padding: 15px 16px 0;
  margin-top:45px;
  .mtitle {
    font-size: 15px;
    color: #000;
    margin: 0px 0 10px;
  }
  .mli {
    padding: 10px 0;
    border-bottom: 1px solid #f1f1f1;
  }
}
</style>